package com.rykj.qxj.test.xtest;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.rykj.qxj.server.model.entity.AddField;
import com.rykj.qxj.server.model.entity.ApiRequestParam;
import com.rykj.qxj.server.model.entity.ApiResponseParam;
import com.rykj.qxj.server.model.entity.UpdateField;

public class ObjectFiledEquals {
	public static void main(String[] args) {
		ApiRequestParam arp=new ApiRequestParam();
		arp.setName("a_name");
		arp.setPenName("name");
		ApiRequestParam barp=new ApiRequestParam();
		barp.setName("b_name");
		barp.setPenName("name");
		ApiRequestParam carp=new ApiRequestParam();
		carp.setName("c_name");
		carp.setPenName("cname");
		ApiRequestParam darp=new ApiRequestParam();
		darp.setName("d_name");
		darp.setPenName("dname");
		ApiRequestParam earp=new ApiRequestParam();
		earp.setName("e_name");
		earp.setPenName("ename");
		List<ApiRequestParam> apiRequestParamList=new ArrayList<ApiRequestParam>();
		apiRequestParamList.add(arp);
		apiRequestParamList.add(barp);
		apiRequestParamList.add(carp);
		apiRequestParamList.add(darp);
		apiRequestParamList.add(earp);
		if(isApiRequestParamDuplicatePenName(apiRequestParamList)) {
			System.out.println("请求参数的笔名有重复值请检查!");
		}else {
			System.out.println("验证通过");
		}
		
		
	}
	private static boolean isApiRequestParamDuplicatePenName(List<ApiRequestParam> apiRequestParamList) {
		List<String> exitPenNames=new ArrayList<String>();
		Set<String>  distinctPenNames=new HashSet<String>();
		for (ApiRequestParam apiRequestParam : apiRequestParamList) {
			exitPenNames.add(apiRequestParam.getPenName());
			distinctPenNames.add(apiRequestParam.getPenName());
		}
		if(exitPenNames.size()!=distinctPenNames.size()) {
			return true;
		}else {
			return false;
		}
	}
	private static boolean isApiResponseParamDuplicatePenName(List<ApiResponseParam> apiResponseParamList) {
		List<String> exitPenNames=new ArrayList<String>();
		Set<String>  distinctPenNames=new HashSet<String>();
		for (ApiResponseParam apiResponseParam : apiResponseParamList) {
			exitPenNames.add(apiResponseParam.getPenName());
			distinctPenNames.add(apiResponseParam.getPenName());
		}
		if(exitPenNames.size()!=distinctPenNames.size()) {
			return true;
		}else {
			return false;
		}
	}
	private static boolean isAddFieldDuplicatePenName(List<AddField> addFieldList) {
		List<String> exitPenNames=new ArrayList<String>();
		Set<String>  distinctPenNames=new HashSet<String>();
		for (AddField addField : addFieldList) {
			exitPenNames.add(addField.getPenName());
			distinctPenNames.add(addField.getPenName());
		}
		if(exitPenNames.size()!=distinctPenNames.size()) {
			return true;
		}else {
			return false;
		}
	}
	private static boolean isUpdateFieldDuplicatePenName(List<UpdateField> updateFieldList) {
		List<String> exitPenNames=new ArrayList<String>();
		Set<String>  distinctPenNames=new HashSet<String>();
		for (UpdateField updateField : updateFieldList) {
			exitPenNames.add(updateField.getPenName());
			distinctPenNames.add(updateField.getPenName());
		}
		if(exitPenNames.size()!=distinctPenNames.size()) {
			return true;
		}else {
			return false;
		}
	}
}
